beautifulsoup docs

26

from bs4 import BeautifulSoup

with open("index.html") as fp:
    soup = BeautifulSoup(fp)

soup = BeautifulSoup("<html>a web page</html>")
def has_class_but_no_id(tag):
    return tag.has_attr('class') and not tag.has_attr('id')
soup = BeautifulSoup('<b class="boldest">Extremely bold</b>', 'html.parser')
tag = soup.b
type(tag)
# <class 'bs4.element.Tag'>

Comments

Submit
0 Comments